package com.thirteengroup.casemg.service.impl;

import com.thirteengroup.casemg.domain.Employee;
import com.thirteengroup.casemg.domain.PageResult;
import com.thirteengroup.casemg.domain.queryObject;
import com.thirteengroup.casemg.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class EmployeeService implements IEmployeeService {

    @Autowired
    private com.thirteengroup.casemg.Mapper.employeeMapper employeeMapper;

    @Override
    public List<Employee> queryAllEmployee() {
        List<Employee> list=new ArrayList<>();
        int count=employeeMapper.selectCount();
        List<Employee> employeeList=employeeMapper.selectAll();
        return employeeList;
    }

    @Override
    public void deleteById(Long id) {
        employeeMapper.deleteById(id);
    }

    @Override
    public Employee slectOne(Long id) {
        Employee employee=employeeMapper.selectOne(id);
        return employee;
    }

    @Override
    public void insertDept(Employee employee) {
        employeeMapper.insert(employee);
    }

    @Override
    public void updateDept(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public PageResult<Employee> selectLimit(queryObject queryObject) {
        PageResult<Employee> pageResult=null;
        int count=employeeMapper.selectCount();
        List<Employee> employeeList=employeeMapper.selectLimit(queryObject);
        pageResult=new PageResult<>(queryObject.getCurrentPage(),count,queryObject.getPageSize(),employeeList);
        return pageResult;
    }

    @Override
    public void batchInsert(List<Employee> employeeList) {
        employeeMapper.batchInsert(employeeList);
    }


}
